<?php
/**
*用于按照一定规律拆分数组
*
* @author      林家俊(XXX@XXX.com)
* @version     1.0
*/

$values = range(1, 31);
$rows = array_chunk($values, 7);

print "<table> ";
foreach ($rows as $row) {
    print "<tr> ";
    foreach ($row as $value) {
        print "<td>" . $value . "</td> ";
    }
    print "</tr> ";
}
print "</table><br/><br/><br/><br/> ";


$values1 = range(1, 12);
$rows1 = array_chunk($values1, 6);

var_dump(dump($rows1));

function dump($vars, $label = '', $return = false) {
    if (ini_get('html_errors')) {
        $content = "<pre>\n";
        if ($label != '') {
            $content .= "<strong>{$label} :</strong>\n";
        }
        $content .= htmlspecialchars(print_r($vars, true));
        $content .= "\n</pre>\n";
    } else {
        $content = $label . " :\n" . print_r($vars, true);
    }
    if ($return) { return $content; }
    echo $content;
}
?>

